package java03;

public class work04 {
public static void main(String[] args) {
	int n=0;
	for(int i=0;i<1000;i++){
		if(isSuShu(i)&&isHuiWenShu(i)){
			System.out.printf(i+" ");
			n++;
			if(n%10==0){
				System.out.println("\n");
			}
		}
	}
}

private static boolean isHuiWenShu(int num) {
	if (num < 2) {
        return false;
    }
    for (int i = 2; i <= Math.sqrt(num); i++) {
        if (num % i == 0) {
            return false;
        }
    }
    return true;
}

private static boolean isSuShu(int num) {
	
    String numberStr = Integer.toString(num);

    StringBuilder reversedStr = new StringBuilder(numberStr).reverse();
    int reversedNum = Integer.parseInt(reversedStr.toString());

    return num == reversedNum;
}
}